<cfcomponent>
	<cffunction name="getMasterQuery" output="false" access="remote" returntype="query">
		<cfargument name="ID" required="false">
		<cfset var qRead="">

		<cfquery name="qRead" datasource="BRUST">
			SELECT     
				TOP 100 PERCENT dbo.Instituicao.institucaoId, dbo.Instituicao.nome, dbo.Instituicao.responsavel, 
				COUNT(dbo.Equipamento.equipamentoId) AS equipamentosCount, COUNT(dbo.Medicao.medicaoId) AS medicoesCount
			FROM
			  	dbo.Medicao RIGHT OUTER JOIN
                dbo.Equipamento ON dbo.Medicao.equipamentoId = dbo.Equipamento.equipamentoId RIGHT OUTER JOIN
               	dbo.Instituicao ON dbo.Equipamento.institucaoId = dbo.Instituicao.institucaoId
			GROUP BY 
				dbo.Instituicao.institucaoId, dbo.Instituicao.nome, dbo.Instituicao.responsavel
			ORDER BY 
				dbo.Instituicao.nome 
		</cfquery>

		<cfreturn qRead>
	</cffunction>

	<cffunction name="deleteItem" output="false" access="remote" returntype="void">
		<cfargument name="ID" required="true">

		<cfscript>
			InstituicaoGateway = createObject("component", "slr.components.cfgenerated.Instituicao_Detail.InstituicaoGateway");
			InstituicaoGateway.deleteByID(arguments.ID);
		</cfscript>
	</cffunction>
</cfcomponent>
